const fs = require('fs')
let user = { username: "admin111", password: "12345" }

let result = fs.readFileSync('shuju.json', { encoding: 'utf8' })
let res = Object.values(JSON.parse(result))

let a = res.findIndex(item =>item.username == user.username )
if (a == -1) {
    console.log('注册成功');
    res.push(user)
} else {
    console.log('账号已注册');
}
let s=JSON.stringify(res)
fs.writeFileSync( 'shuju.json',s,{flag:'w'} )